package com.lsd.game.lastrun.model;

import com.badlogic.gdx.math.Vector2;
import com.lsd.game.lastrun.Constants;

/*
 * This class describes a GENERIC MOVING object. Since the object is moving
 * this class will contain methods on getting and setting speeds and have
 * a velocity vector.
 * 
 * TODO: Where to add collision detection?
 */

public class AbstractMovingObject extends AbstractObject {
	
	/* Class members */
	protected Vector2 velocity; // Used to move the object
	protected float speed; // How fast is this object? (units per sec)
	
	// SUPER CLASS MEMBERS // 
	// private Vector2 position;
	// private Texture texture;
	// private Rectangle debugRect;
	// private float size;
	
	/* Class methods */

	//////////////////
	// CONSTRUCTORS //
	//////////////////
	
	public AbstractMovingObject(Vector2 pos, float objSize, float objSpeed, String textureName) {
		super(pos, objSize, textureName);
		velocity = new Vector2();
		speed = objSpeed;
	}
	
	// SUPER CLASS CONSTRUCTORS //
	public AbstractMovingObject() {
		super();
		velocity = new Vector2();
		speed = Constants.DEFAULT_OBJECT_SPEED;
	}
	
	public AbstractMovingObject(Vector2 pos) {
		super(pos);
		velocity = new Vector2();
		speed = Constants.DEFAULT_OBJECT_SPEED;
	}
	
	public AbstractMovingObject(Vector2 pos, float objSize) {
		super(pos, objSize);
		velocity = new Vector2();
		speed = Constants.DEFAULT_OBJECT_SPEED;
	}
	
	public AbstractMovingObject(Vector2 pos, float objSize, String textureName) {
		super(pos, objSize, textureName);
		velocity = new Vector2();
		speed = Constants.DEFAULT_OBJECT_SPEED;
	}
	
	/////////////////
	// GET METHODS //
	/////////////////
	
	public Vector2 getVelocity() { return velocity; }
	public float getSpeed() { return speed; }
	
	/////////////////
	// SET METHODS //
	/////////////////
	
	public void setVelocity(float newX, float newY) {
		velocity.x = newX;
		velocity.y = newY;
	}
	
	public void setSpeed(float newSpeed) {
		speed = newSpeed;
	}
	
	///////////////////
	// UPDATE METHOD //
	///////////////////
	
	@Override
	public void update(float delta) {
		position.add(velocity.cpy().scl(delta));
	}
	
}
